package wechat.handler.bean.response;

import org.dom4j.DocumentException;

import wechat.handler.response.base.XmlBase;

public class MessageBaseBean extends XmlBase{
	
	// 消息类型--接收
	public static final String Receive_Message_Text = "text";
	public static final String Receive_Message_Image = "image";
	public static final String Receive_Message_Voice = "voice";
	public static final String Receive_Message_Video = "video";
	public static final String Receive_Message_Shortvideo = "shortvideo";
	public static final String Receive_Message_Location = "location";
	public static final String Receive_Message_Link = "link";

	// 消息类型--回复
	public static final String Reply_Message_Text = "text";
	public static final String Reply_Message_Image = "image";
	public static final String Reply_Message_Voice = "voice";
	public static final String Reply_Message_Video = "video";
	public static final String Reply_Message_Music = "music";
	public static final String Reply_Message_News = "news";
	
	//消息类型--事件
	public static final String Message_Event="event";
	
	//事件类型
	public static final String Event_Subscribe = "subscribe";
	public static final String Event_Unsubscribe = "unsubscribe";
	public static final String Event_Scan = "SCAN";
	public static final String Event_Location = "LOCATION";

	public static final String Event_Click = "CLICK";
	public static final String Event_View = "VIEW";
	public static final String Event_ScancodeWaitmsg = "scancode_waitmsg";
	public static final String Event_ScancodePush = "scancode_push";
	public static final String Event_PicSysphoto = "pic_sysphoto";
	public static final String Event_PicPhotoAlbum = "pic_photo_or_album";
	public static final String Event_PicWeixin = "pic_weixin";
	public static final String Event_LocationSelect = "location_select";

	public static final String Event_TemplateSendJobFinish = "TEMPLATESENDJOBFINISH";
	

	
	private String ToUserName;	
	private String FromUserName;
	private long CreateTime;
	private String MsgType;
	private String MsgId;
	private String Encrypt;
	
	public MessageBaseBean(String str) throws DocumentException {
		super(str);
	}
	
	public MessageBaseBean(){
		
	}
	
	public String getToUserName() {
		return ToUserName;
	}
	public void setToUserName(String toUserName) {
		ToUserName = toUserName;
	}
	public String getFromUserName() {
		return FromUserName;
	}
	public void setFromUserName(String fromUserName) {
		FromUserName = fromUserName;
	}
	public long getCreateTime() {
		return CreateTime;
	}
	public void setCreateTime(long createTime) {
		CreateTime = createTime;
	}
	public String getMsgType() {
		return MsgType;
	}
	public void setMsgType(String msgType) {
		MsgType = msgType;
	}
	
	public String getMsgId() {
		return MsgId;
	}

	public void setMsgId(String msgId) {
		MsgId = msgId;
	}

	public String getEncrypt() {
		return Encrypt;
	}

	public void setEncrypt(String encrypt) {
		Encrypt = encrypt;
	}
	
	
	protected static final String Xpath_ToUserName = "/xml/ToUserName";
	protected static final String Xpath_FromUserName = "/xml/FromUserName";
	protected static final String Xpath_CreateTime = "/xml/CreateTime";
	protected static final String Xpath_MsgType = "/xml/MsgType";
	protected static final String Xpath_MsgId = "/xml/MsgId";
	protected static final String Xpath_Encrypt = "/xml/Encrypt";
	
	@Override
	public void transform() throws Exception {
		this.setToUserName(getNodeText(Xpath_ToUserName));
		this.setFromUserName(getNodeText(Xpath_FromUserName));
		this.setCreateTime(Long.valueOf(getNodeText(Xpath_CreateTime)));
		this.setMsgType(getNodeText(Xpath_MsgType));
		this.setMsgId(getNodeText(Xpath_MsgId));
		this.setEncrypt(getNodeText(Xpath_Encrypt));
	}

	@Override
	public String buildXml() throws Exception {
		super.addNodeValue("ToUserName", getToUserName());
		super.addNodeValue("FromUserName", getFromUserName());
		super.addNodeValue("CreateTime", String.valueOf(getCreateTime()));
		super.addNodeValue("MsgType", getMsgType());

		return super.parent.asXML();
	}
	

}
